import request from "./index";

/**
 * 获取基础的信息
 * @param userId {string | number}
 * @returns {Promise}
 */
export function getProfileBase(userId) {
  return request({
    url: "/profile",
    params: {
      userId
    }
  })
}

/**
 * 验证用户是否有资料
 * @returns {Promise}
 */
export function isHaveProfile() {
  return request({
    url: "/profile/isExistProfile"
  })
}

/**
 * 创建我的基本资料
 * @param name {string}
 * @param phone {string}
 * @param gender {string | number}
 * @param birth {string}
 * @param suggest {string}
 * @param qq {string}
 * @param wx {string}
 * @param email {string}
 * @param website {string}
 * @param emotion {string}
 * @param address {string}
 * @returns {Promise}
 */
export function createProfile(name, phone, gender, birth, suggest, qq, wx, email, website, emotion, address) {
  return request({
    url: "/profile",
    method: "POST",
    data: {
      name,
      phone,
      gender,
      birth,
      suggest,
      qq,
      wx,
      email,
      website,
      emotion,
      address
    }
  })
}

/**
 * 更新我的基本资料
 * @param name {string}
 * @param phone {string}
 * @param gender {string | number}
 * @param birth {string}
 * @param suggest {string}
 * @param qq {string}
 * @param wx {string}
 * @param email {string}
 * @param website {string}
 * @param emotion {string}
 * @param address {string}
 * @returns {Promise}
 */
export function updateProfile(name, phone, gender, birth, suggest, qq, wx, email, website, emotion, address) {
  return request({
    url: "/profile",
    method: "PATCH",
    data: {
      name,
      phone,
      gender,
      birth,
      suggest,
      qq,
      wx,
      email,
      website,
      emotion,
      address
    }
  })
}
